package com.dcw.lixb.designmode.strategy;

/**
 * @author lixiaobin
 * @date 2020-07-29 15:53:34
 * @desc 描述信息
 */
public class StrategyMain {
    public static void main(String[] args) {
        Context context = new Context();

        OperationAdd add = new OperationAdd();
        OperationSubtract subtract = new OperationSubtract();
        OperationMultiply multiply = new OperationMultiply();

        int a = 8;
        int b = 9;
        System.out.println("add strategy:");
        context.setStrategy(add);
        System.out.println("ret = "+context.executeStrategy(a, b));

        System.out.println("substract strategy:");
        context.setStrategy(subtract);
        System.out.println("ret = "+context.executeStrategy(a, b));

        System.out.println("multiply strategy:");
        context.setStrategy(multiply);
        System.out.println("ret = "+context.executeStrategy(a, b));

    }
}
